package com.candy.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class DBHelper4IUD {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url="jdbc:mysql://localhost:3306/ld_mysql0317? characterEncoding=utf8 & useSSL=false & serverTimezone=UTC & rewriteBatchedStatements=true";
            String username="root";
            String password="123456";
            Connection conn=DriverManager.getConnection(url,username,password);
            Statement ment=conn.createStatement();
//            新增操作
//            String sql="INSERT INTO userinfo(username,userpwd,useraddress,usertel) VALUES('哪吒','123456','天津陈塘关','14569856988');";
//           修改操作
//            String sql="UPDATE userinfo SET userpwd='666666' WHERE id=78;";
//           删除操作
            String sql="DELETE FROM userinfo WHERE id=78;";
            int num=ment.executeUpdate(sql);
            System.out.println(num);
            ment.close();
            conn.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
